*********************************** * * * */SYSTEM/START * * Program Code * * Interpreted by Sandy Mossberg * * * * Copyright (C) 1988 * * by MicroSPARC, Inc. * * Concord, MA 01742 * * * *********************************** ; Equate: PRODOS GEQU $E100A8 ;ProDOS 16 call Start_File START ; Equate data bank to program bank: Start_Body PHK PLB ; Calculate amount of usable RAM PHA ;reserve work area on PHA ; stack (4 bytes) JSL >GoGetRAM ;get size of usable RAM LDA $03,S ;result left on stack CMP #4 BCC AltQuit ;less than 256K found ; Primary QUIT command: JSL PRODOS ;used if >= 256K usable RAM DC I2'$29' ;QUIT command code MQParmPtr DC I4'MQuitParm' ;pointer to parmlist ; Alternate QUIT command: AltQuit JSL PRODOS ;used if < 256K usable RAM DC I2'$29' ;QUIT command code AQParmPtr DC I4'AQuitParm' ;pointer to parmlist ; Primary QUIT parameter list: MQuitParm DC I4'MQuitName' ;pointer to pathname DC I2'$00' ;return/restart flags ; Alternate QUIT parameter list: AQuitParm DC I4'AQuitName' ;pointer to pathname DC I2'$00' ;return/restart flags ; Pathname of primary START file: MQuitName DC I1'$0F' ;length byte DC C'*/SYSTEM/FINDER' ; Pathname of alternate START file: AQuitName DC I1'$11' ;length byte DC C'*/SYSTEM/LAUNCHER' ; Call subroutine to calculate usable RAM: ; ; EXIT: usable RAM on stack bytes 1-4 (L-ML-MH-H): GoGetRAM JSL >GetRAM ;get size of unpurgeable RAM RTL ; Subroutine to calculate usable RAM: ; ; EXIT: usable RAM on stack bytes 4-7 (L-ML-MH-H): ;--> Transform stack into work area for calculations: GetRAM PHD ;save entry direct page PHA ;save return address PHA ; on stack TSC ;equate stack and TCD ; direct page STZ $0D ;zero storage bytes for STZ $0F ; RAM calculations ;--> Point to Memory Manager's allocated block records: LDA $E11600 TAX LDA $E11602 GR1 STX $01 ;pointers to block records STA $03 ; at $00-$03 ;--> Test block attributes: LDY #4 LDA [$01],Y ;get attributes AND #$0300 ;isolate purge level BNE GR2 ;block purgeable so skip it ;--> Calculate total size of unpurgeable (unusable) RAM: LDY #8 ;block unpurgeable LDA [$01],Y ;get block size lo CLC ; and save it ADC $0D ; at $0C-$0D of STA $0D ; direct page (also stack) INY ;bump index to INY ; hi order byte LDA [$01],Y ;get block size hi ADC $0F ; and save it STA $0F ; at $0E-$0F of GR2 LDY #$10 ; direct page (also stack) LDA [$01],Y ;get link lo to next TAX ; block record INY ;bump index to INY ; hi order byte LDA [$01],Y ;get link to to next record BNE GR1 ;not at last record ;--> Subtract from $100000000 to get total usable RAM: LDA #0 ;all block records checked TAX ; so calculate complement SEC ; of total block sizes SBC $0D ; stored at $0C-$0F STA $0D TXA SBC $0F STA $0F PLA ;restore return address and PLA ; direct page to entry PLD ; values (former $0C-$0F at RTL ; $04-$07 after RTL) END